home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 4: GNU Archives / Linux Cubed Series 4 - GNU Archives.iso / gnu / binutils.7 / binutils / binutils-2.7 / ld / scripttempl / elf.sc < prev    next >
Encoding:
Text File  |  1996-07-04  |  5.8 KB  |  149 lines

  1. #
  2. # Unusual variables checked by this code:
  3. #    NOP - two byte opcode for no-op (defaults to 0)
  4. #    DATA_ADDR - if end-of-text-plus-one-page isn't right for data start
  5. #    OTHER_READONLY_SECTIONS - other than .text .init .rodata ...
  6. #        (e.g., .PARISC.milli)
  7. #    OTHER_READWRITE_SECTIONS - other than .data .bss .ctors .sdata ...
  8. #        (e.g., .PARISC.global)
  9. #    OTHER_SECTIONS - at the end
  10. #    EXECUTABLE_SYMBOLS - symbols that must be defined for an
  11. #        executable (e.g., _DYNAMIC_LINK)
  12. #    TEXT_START_SYMBOLS - symbols that appear at the start of the
  13. #        .text section.
  14. #    DATA_START_SYMBOLS - symbols that appear at the start of the
  15. #        .data section.
  16. #    OTHER_BSS_SYMBOLS - symbols that appear at the start of the
  17. #        .bss section besides __bss_start.
  18. #    DATA_PLT - .plt should be in data segment, not text segment.
  19. #
  20. # When adding sections, do note that the names of some sections are used
  21. # when specifying the start address of the next.
  22. #
  23. test -z "$ENTRY" && ENTRY=_start
  24. test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT}
  25. test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT}
  26. if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi
  27. test "$LD_FLAG" = "N" && DATA_ADDR=.
  28. INTERP=".interp   ${RELOCATING-0} : { *(.interp)     }"
  29. PLT=".plt    ${RELOCATING-0} : { *(.plt)    }"
  30. cat <<EOF
  31. OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
  32.           "${LITTLE_OUTPUT_FORMAT}")
  33. OUTPUT_ARCH(${OUTPUT_ARCH})
  34. ENTRY(${ENTRY})
  35.  
  36. ${RELOCATING+${LIB_SEARCH_DIRS}}
  37. ${RELOCATING+/* Do we need any of these for elf?
  38.    __DYNAMIC = 0; ${STACKZERO+${STACKZERO}} ${SHLIB_PATH+${SHLIB_PATH}}  */}
  39. ${RELOCATING+${EXECUTABLE_SYMBOLS}}
  40. ${RELOCATING- /* For some reason, the Solaris linker makes bad executables
  41.   if gld -r is used and the intermediate file has sections starting
  42.   at non-zero addresses.  Could be a Solaris ld bug, could be a GNU ld
  43.   bug.  But for now assigning the zero vmas works.  */}
  44. SECTIONS
  45. {
  46.   /* Read-only sections, merged into text segment: */
  47.   ${CREATE_SHLIB-${RELOCATING+. = ${TEXT_START_ADDR} + SIZEOF_HEADERS;}}
  48.   ${CREATE_SHLIB+${RELOCATING+. = SIZEOF_HEADERS;}}
  49.   ${CREATE_SHLIB-${INTERP}}
  50.   .hash        ${RELOCATING-0} : { *(.hash)        }
  51.   .dynsym      ${RELOCATING-0} : { *(.dynsym)        }
  52.   .dynstr      ${RELOCATING-0} : { *(.dynstr)        }
  53.   .rel.text    ${RELOCATING-0} : { *(.rel.text)        }
  54.   .rela.text   ${RELOCATING-0} : { *(.rela.text)     }
  55.   .rel.data    ${RELOCATING-0} : { *(.rel.data)        }
  56.   .rela.data   ${RELOCATING-0} : { *(.rela.data)     }
  57.   .rel.rodata  ${RELOCATING-0} : { *(.rel.rodata)     }
  58.   .rela.rodata ${RELOCATING-0} : { *(.rela.rodata)     }
  59.   .rel.got     ${RELOCATING-0} : { *(.rel.got)        }
  60.   .rela.got    ${RELOCATING-0} : { *(.rela.got)        }
  61.   .rel.ctors   ${RELOCATING-0} : { *(.rel.ctors)    }
  62.   .rela.ctors  ${RELOCATING-0} : { *(.rela.ctors)    }
  63.   .rel.dtors   ${RELOCATING-0} : { *(.rel.dtors)    }
  64.   .rela.dtors  ${RELOCATING-0} : { *(.rela.dtors)    }
  65.   .rel.init    ${RELOCATING-0} : { *(.rel.init)    }
  66.   .rela.init   ${RELOCATING-0} : { *(.rela.init)    }
  67.   .rel.fini    ${RELOCATING-0} : { *(.rel.fini)    }
  68.   .rela.fini   ${RELOCATING-0} : { *(.rela.fini)    }
  69.   .rel.bss     ${RELOCATING-0} : { *(.rel.bss)        }
  70.   .rela.bss    ${RELOCATING-0} : { *(.rela.bss)        }
  71.   .rel.plt     ${RELOCATING-0} : { *(.rel.plt)        }
  72.   .rela.plt    ${RELOCATING-0} : { *(.rela.plt)        }
  73.   .init        ${RELOCATING-0} : { *(.init)    } =${NOP-0}
  74.   ${DATA_PLT-${PLT}}
  75.   .text    ${RELOCATING-0} :
  76.   {
  77.     ${RELOCATING+${TEXT_START_SYMBOLS}}
  78.     *(.text)
  79.     /* .gnu.warning sections are handled specially by elf32.em.  */
  80.     *(.gnu.warning)
  81.   } =${NOP-0}
  82.   ${RELOCATING+_etext = .;}
  83.   ${RELOCATING+PROVIDE (etext = .);}
  84.   .fini    ${RELOCATING-0} : { *(.fini)    } =${NOP-0}
  85.   .rodata  ${RELOCATING-0} : { *(.rodata)  }
  86.   .rodata1 ${RELOCATING-0} : { *(.rodata1) }
  87.   ${RELOCATING+${OTHER_READONLY_SECTIONS}}
  88.  
  89.   /* Adjust the address for the data segment.  We want to adjust up to
  90.      the same address within the page on the next page up.  */
  91.   ${RELOCATING+. = ${DATA_ADDR-ALIGN(${MAXPAGESIZE}) + (ALIGN(8) & (${MAXPAGESIZE} - 1))};}
  92.  
  93.   .data  ${RELOCATING-0} :
  94.   {
  95.     ${RELOCATING+${DATA_START_SYMBOLS}}
  96.     *(.data)
  97.     ${CONSTRUCTING+CONSTRUCTORS}
  98.   }
  99.   .data1 ${RELOCATING-0} : { *(.data1) }
  100.   ${RELOCATING+${OTHER_READWRITE_SECTIONS}}
  101.   .ctors       ${RELOCATING-0} : { *(.ctors)   }
  102.   .dtors       ${RELOCATING-0} : { *(.dtors)   }
  103.   .got         ${RELOCATING-0} : { *(.got.plt) *(.got) }
  104.   .dynamic     ${RELOCATING-0} : { *(.dynamic) }
  105.   ${DATA_PLT+${PLT}}
  106.   /* We want the small data sections together, so single-instruction offsets
  107.      can access them all, and initialized data all before uninitialized, so
  108.      we can shorten the on-disk segment size.  */
  109.   .sdata   ${RELOCATING-0} : { *(.sdata) }
  110.   ${RELOCATING+_edata  =  .;}
  111.   ${RELOCATING+PROVIDE (edata = .);}
  112.   ${RELOCATING+__bss_start = .;}
  113.   ${RELOCATING+${OTHER_BSS_SYMBOLS}}
  114.   .sbss    ${RELOCATING-0} : { *(.sbss) *(.scommon) }
  115.   .bss     ${RELOCATING-0} :
  116.   {
  117.    *(.dynbss)
  118.    *(.bss)
  119.    *(COMMON)
  120.   }
  121.   ${RELOCATING+_end = . ;}
  122.   ${RELOCATING+PROVIDE (end = .);}
  123.  
  124.   /* Stabs debugging sections.  */
  125.   .stab 0 : { *(.stab) }
  126.   .stabstr 0 : { *(.stabstr) }
  127.   .stab.excl 0 : { *(.stab.excl) }
  128.   .stab.exclstr 0 : { *(.stab.exclstr) }
  129.   .stab.index 0 : { *(.stab.index) }
  130.   .stab.indexstr 0 : { *(.stab.indexstr) }
  131.  
  132.   .comment 0 : { *(.comment) }
  133.  
  134.   /* DWARF debug sections.
  135.      Symbols in the .debug DWARF section are relative to the beginning of the
  136.      section so we begin .debug at 0.  It's not clear yet what needs to happen
  137.      for the others.   */
  138.   .debug          0 : { *(.debug) }
  139.   .debug_srcinfo  0 : { *(.debug_srcinfo) }
  140.   .debug_aranges  0 : { *(.debug_aranges) }
  141.   .debug_pubnames 0 : { *(.debug_pubnames) }
  142.   .debug_sfnames  0 : { *(.debug_sfnames) }
  143.   .line           0 : { *(.line) }
  144.  
  145.   /* These must appear regardless of ${RELOCATING}.  */
  146.   ${OTHER_SECTIONS}
  147. }
  148. EOF
  149.